/**
 * Copyright (c) 2011 eelpo.com
 * All rights reserved.
 */
package com.eelpo.cmmp.uac.dao.vo;

import java.io.Serializable;

import com.eelpo.cmmp.uac.dao.vo.enumed.FilterMode;
import com.eelpo.common.util.BlankUtils;

/**
 * <pre>
 * 
 * 用户IP过滤规则
 * 
 * </pre>
 * 
 * @author <a href="mailto:Brian@eelpo.com">汪洪州</a>
 * @since 1.0
 */
public class UserIpFilter implements Serializable {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 7455034195054886447L;

	/**
	 * 过滤ID
	 */
	private String id;

	/**
	 * ip号码头
	 */
	private String head;

	/**
	 * 开始地址
	 */
	private String start;

	/**
	 * 结束地址
	 */
	private String offset;

	/**
	 * 过滤方式
	 */
	private FilterMode filterMode;

	public UserIpFilter() {

	}

	public UserIpFilter(String id) {
		this.id = id;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getHead() {
		return head;
	}

	public void setHead(String head) {
		this.head = head;
	}

	public String getStart() {
		return start;
	}

	public void setStart(String start) {
		this.start = start;
	}

	public String getOffset() {
		return offset;
	}

	public void setOffset(String offset) {
		this.offset = offset;
	}

	public FilterMode getFilterMode() {
		return filterMode;
	}

	public void setFilterMode(FilterMode filterMode) {
		this.filterMode = filterMode;
	}

	@Override
	public boolean equals(Object obj) {
		if (BlankUtils.isBlank(obj) || !(obj instanceof UserIpFilter))
			return false;

		if (this == obj)
			return true;

		UserIpFilter filter = (UserIpFilter) obj;

		if (BlankUtils.isBlank(this.id) || BlankUtils.isBlank(filter.getId())) {
			return false;
		}

		return this.id.equals(filter.getId());
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public String toString() {
		return head + start + "-" + offset;
	}

}
